home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / swingall.jar / javax / swing / text / StyleContext$NamedStyle.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-07-15  |  5.3 KB  |  176 lines

  1. package javax.swing.text;
  2.  
  3. import java.io.IOException;
  4. import java.io.ObjectInputStream;
  5. import java.io.ObjectOutputStream;
  6. import java.io.Serializable;
  7. import java.util.Enumeration;
  8. import javax.swing.event.ChangeEvent;
  9. import javax.swing.event.ChangeListener;
  10. import javax.swing.event.EventListenerList;
  11.  
  12. public class StyleContext$NamedStyle implements Style, Serializable {
  13.    // $FF: synthetic field
  14.    private final StyleContext this$0;
  15.    protected EventListenerList listenerList;
  16.    protected transient ChangeEvent changeEvent;
  17.    private transient AttributeSet attributes;
  18.  
  19.    public StyleContext$NamedStyle(StyleContext var1) {
  20.       this.this$0 = var1;
  21.       this.listenerList = new EventListenerList();
  22.       this.changeEvent = null;
  23.       this.attributes = var1.getEmptySet();
  24.    }
  25.  
  26.    public StyleContext$NamedStyle(StyleContext var1, String var2, Style var3) {
  27.       this.this$0 = var1;
  28.       this.listenerList = new EventListenerList();
  29.       this.changeEvent = null;
  30.       this.attributes = var1.getEmptySet();
  31.       if (var2 != null) {
  32.          this.setName(var2);
  33.       }
  34.  
  35.       if (var3 != null) {
  36.          this.setResolveParent(var3);
  37.       }
  38.  
  39.    }
  40.  
  41.    public StyleContext$NamedStyle(StyleContext var1, Style var2) {
  42.       this(var1, (String)null, var2);
  43.    }
  44.  
  45.    public void addAttribute(Object var1, Object var2) {
  46.       StyleContext var3 = this.this$0;
  47.       this.attributes = var3.addAttribute(this.attributes, var1, var2);
  48.       this.fireStateChanged();
  49.    }
  50.  
  51.    public void addAttributes(AttributeSet var1) {
  52.       StyleContext var2 = this.this$0;
  53.       this.attributes = var2.addAttributes(this.attributes, var1);
  54.       this.fireStateChanged();
  55.    }
  56.  
  57.    public void addChangeListener(ChangeListener var1) {
  58.       this.listenerList.add(StyleContext.class$javax$swing$event$ChangeListener != null ? StyleContext.class$javax$swing$event$ChangeListener : (StyleContext.class$javax$swing$event$ChangeListener = StyleContext.class$("javax.swing.event.ChangeListener")), var1);
  59.    }
  60.  
  61.    public boolean containsAttribute(Object var1, Object var2) {
  62.       return this.attributes.containsAttribute(var1, var2);
  63.    }
  64.  
  65.    public boolean containsAttributes(AttributeSet var1) {
  66.       return this.attributes.containsAttributes(var1);
  67.    }
  68.  
  69.    public AttributeSet copyAttributes() {
  70.       StyleContext$NamedStyle var1 = new StyleContext$NamedStyle(this.this$0);
  71.       var1.attributes = this.attributes.copyAttributes();
  72.       return var1;
  73.    }
  74.  
  75.    protected void fireStateChanged() {
  76.       Object[] var1 = this.listenerList.getListenerList();
  77.  
  78.       for(int var2 = var1.length - 2; var2 >= 0; var2 -= 2) {
  79.          if (var1[var2] == (StyleContext.class$javax$swing$event$ChangeListener != null ? StyleContext.class$javax$swing$event$ChangeListener : (StyleContext.class$javax$swing$event$ChangeListener = StyleContext.class$("javax.swing.event.ChangeListener")))) {
  80.             if (this.changeEvent == null) {
  81.                this.changeEvent = new ChangeEvent(this);
  82.             }
  83.  
  84.             ((ChangeListener)var1[var2 + 1]).stateChanged(this.changeEvent);
  85.          }
  86.       }
  87.  
  88.    }
  89.  
  90.    public Object getAttribute(Object var1) {
  91.       return this.attributes.getAttribute(var1);
  92.    }
  93.  
  94.    public int getAttributeCount() {
  95.       return this.attributes.getAttributeCount();
  96.    }
  97.  
  98.    public Enumeration getAttributeNames() {
  99.       return this.attributes.getAttributeNames();
  100.    }
  101.  
  102.    public String getName() {
  103.       return this.isDefined(StyleConstants.NameAttribute) ? (String)this.getAttribute(StyleConstants.NameAttribute) : null;
  104.    }
  105.  
  106.    public AttributeSet getResolveParent() {
  107.       return this.attributes.getResolveParent();
  108.    }
  109.  
  110.    public boolean isDefined(Object var1) {
  111.       return this.attributes.isDefined(var1);
  112.    }
  113.  
  114.    public boolean isEqual(AttributeSet var1) {
  115.       return this.attributes.isEqual(var1);
  116.    }
  117.  
  118.    private void readObject(ObjectInputStream var1) throws ClassNotFoundException, IOException {
  119.       var1.defaultReadObject();
  120.       this.attributes = SimpleAttributeSet.EMPTY;
  121.       StyleContext.readAttributeSet(var1, this);
  122.    }
  123.  
  124.    public void removeAttribute(Object var1) {
  125.       StyleContext var2 = this.this$0;
  126.       this.attributes = var2.removeAttribute(this.attributes, var1);
  127.       this.fireStateChanged();
  128.    }
  129.  
  130.    public void removeAttributes(Enumeration var1) {
  131.       StyleContext var2 = this.this$0;
  132.       this.attributes = var2.removeAttributes(this.attributes, var1);
  133.       this.fireStateChanged();
  134.    }
  135.  
  136.    public void removeAttributes(AttributeSet var1) {
  137.       StyleContext var2 = this.this$0;
  138.       if (var1 == this) {
  139.          this.attributes = var2.getEmptySet();
  140.       } else {
  141.          this.attributes = var2.removeAttributes(this.attributes, var1);
  142.       }
  143.  
  144.       this.fireStateChanged();
  145.    }
  146.  
  147.    public void removeChangeListener(ChangeListener var1) {
  148.       this.listenerList.remove(StyleContext.class$javax$swing$event$ChangeListener != null ? StyleContext.class$javax$swing$event$ChangeListener : (StyleContext.class$javax$swing$event$ChangeListener = StyleContext.class$("javax.swing.event.ChangeListener")), var1);
  149.    }
  150.  
  151.    public void setName(String var1) {
  152.       if (var1 != null) {
  153.          this.addAttribute(StyleConstants.NameAttribute, var1);
  154.       }
  155.  
  156.    }
  157.  
  158.    public void setResolveParent(AttributeSet var1) {
  159.       if (var1 != null) {
  160.          this.addAttribute(StyleConstants.ResolveAttribute, var1);
  161.       } else {
  162.          this.removeAttribute(StyleConstants.ResolveAttribute);
  163.       }
  164.  
  165.    }
  166.  
  167.    public String toString() {
  168.       return "NamedStyle:" + this.getName() + " " + this.attributes;
  169.    }
  170.  
  171.    private void writeObject(ObjectOutputStream var1) throws IOException {
  172.       var1.defaultWriteObject();
  173.       StyleContext.writeAttributeSet(var1, this.attributes);
  174.    }
  175. }
  176.